home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / unix / c / ioctl < prev    next >
Text File  |  1996-11-09  |  1KB  |  61 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/ioctl,v $
  4.  * $Date: 1996/11/06 22:01:42 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: ioctl,v $
  10.  * Revision 1.2  1996/11/06 22:01:42  unixlib
  11.  * Yet more changes by NB, PB and SC.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:35:27  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. static const char rcs_id[] = "$Id: ioctl,v 1.2 1996/11/06 22:01:42 unixlib Rel $";
  19.  
  20. #include <errno.h>
  21. #include <termio.h>
  22.  
  23. #include <sys/ioctl.h>
  24. #include <sys/syslib.h>
  25. #include <sys/unix.h>
  26. #include <sys/dev.h>
  27.  
  28. int
  29. ioctl (int fd, register int request, void *arg)
  30. {
  31.   register struct file *f;
  32.  
  33.   if (!arg)
  34.     {
  35.       errno = EINVAL;
  36.       return (-1);
  37.     }
  38.  
  39.   if (BADF (fd))
  40.     {
  41.       errno = EBADF;
  42.       return (-1);
  43.     }
  44.  
  45.   f = __u->file + fd;
  46.  
  47.   return __funcall ((*__dev[major (f->dev)].ioctl), (minor (f->dev), request, arg, f));
  48. }
  49.  
  50. int
  51. gtty (register int fd, register struct termio *t)
  52. {
  53.   return (ioctl (fd, TCGETA, t));
  54. }
  55.  
  56. int
  57. stty (register int fd, register struct termio *t)
  58. {
  59.   return (ioctl (fd, TCSETA, t));
  60. }
  61.